package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CaseMalfeasanceLiable;
import com.ktgj.customer.service.ICaseMalfeasanceLiableService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 渎失职责任Controller
 * 
 * @author ruoyi
 * @date 2022-05-25
 */
@RestController
@RequestMapping("/liable")
public class CaseMalfeasanceLiableController extends BaseController
{
    @Autowired
    private ICaseMalfeasanceLiableService caseMalfeasanceLiableService;

    /**
     * 查询渎失职责任列表
     */
    @PreAuthorize(hasPermi = "system:liable:list")
    @GetMapping("/list")
    public TableDataInfo list(CaseMalfeasanceLiable caseMalfeasanceLiable)
    {
        startPage();
        List<CaseMalfeasanceLiable> list = caseMalfeasanceLiableService.selectCaseMalfeasanceLiableList(caseMalfeasanceLiable);
        return getDataTable(list);
    }

    /**
     * 导出渎失职责任列表
     */
    @PreAuthorize(hasPermi = "system:liable:export")
    @Log(title = "渎失职责任", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaseMalfeasanceLiable caseMalfeasanceLiable) throws IOException
    {
        List<CaseMalfeasanceLiable> list = caseMalfeasanceLiableService.selectCaseMalfeasanceLiableList(caseMalfeasanceLiable);
        ExcelUtil<CaseMalfeasanceLiable> util = new ExcelUtil<CaseMalfeasanceLiable>(CaseMalfeasanceLiable.class);
        util.exportExcel(response, list, "渎失职责任数据");
    }

    /**
     * 获取渎失职责任详细信息
     */
    @PreAuthorize(hasPermi = "system:liable:query")
    @GetMapping(value = "/{caseMalfeasanceLiableId}")
    public AjaxResult getInfo(@PathVariable("caseMalfeasanceLiableId") Long caseMalfeasanceLiableId)
    {
        return AjaxResult.success(caseMalfeasanceLiableService.selectCaseMalfeasanceLiableById(caseMalfeasanceLiableId));
    }

    /**
     * 新增渎失职责任
     */
    @PreAuthorize(hasPermi = "system:liable:add")
    @Log(title = "渎失职责任", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaseMalfeasanceLiable caseMalfeasanceLiable)
    {
        return toAjax(caseMalfeasanceLiableService.insertCaseMalfeasanceLiable(caseMalfeasanceLiable));
    }

    /**
     * 修改渎失职责任
     */
    @PreAuthorize(hasPermi = "system:liable:edit")
    @Log(title = "渎失职责任", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaseMalfeasanceLiable caseMalfeasanceLiable)
    {
        return toAjax(caseMalfeasanceLiableService.updateCaseMalfeasanceLiable(caseMalfeasanceLiable));
    }

    /**
     * 删除渎失职责任
     */
    @PreAuthorize(hasPermi = "system:liable:remove")
    @Log(title = "渎失职责任", businessType = BusinessType.DELETE)
	@DeleteMapping("/{caseMalfeasanceLiableIds}")
    public AjaxResult remove(@PathVariable Long[] caseMalfeasanceLiableIds)
    {
        return toAjax(caseMalfeasanceLiableService.deleteCaseMalfeasanceLiableByIds(caseMalfeasanceLiableIds));
    }
}
